/**
 * 
 */
package com.jc.framework.web;

/**
 * 规则：<br>
 * 1开头，表示成功<br>
 * 2开头，标示失败
 */
public enum ErrorEnum{
	
	/*****************************请求成功*****************************/
	C10000(10000,"成功"),
	C20000(20000,"请求失败!");
	/*****************************************************************/
	private int code;
	private String message;
	private String desc;

	private ErrorEnum(int code,String message) {
        this.code = code;
        this.message = message;
    }

	private ErrorEnum(int code,String message,String desc) {
        this.code = code;
        this.message = message;
        this.desc = desc;
    }
	
	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}
	
	public String getDesc() {
		if(desc == null){
			return message;
		}
		return desc;
	}

	public static ErrorEnum getError(int code) {
		for(ErrorEnum error : ErrorEnum.values()) {
			if(error.code==code) {
				return error;
			}
		}
		return null;
	}
	
}
